using System;
using System.Collections;
using System.Collections.Specialized;
using System.Runtime.InteropServices;
namespace BMC.ARSystem
{
	[ClassInterface, ComVisible(false), Guid("06c6563f-987a-4925-b5cc-5469bc7b7ef2"), ProgId("BMC.ARSystem.Container")]
	public abstract class Container
	{
		[Guid("162a54d5-ebac-42e8-a5ec-a8d7c97fe078")]
		public enum MemberFlags
		{
			Name = 1,
			NewName,
			Permissions = 4,
			AdminGroups = 8,
			Ownerobjs = 16,
			Label = 32,
			Description = 64,
			ContainerType = 128,
			Referecences = 256,
			HelpText = 512,
			Owner = 1024,
			ChangeDiary = 2048,
			Properties = 4096,
			LastUpdateTime = 8192,
			LastModifiedBy = 16384,
			ModificationLogLabel = 32768,
			AssignedGroupList = 65536,
			AssignedName = 131072
		}
		[ARStructMemTypeInfo(Name = "containerName", Offset = 3u)]
		private string _name;
		[ARStructMemTypeInfo(Name = "permList", Offset = 5u)]
		private ArrayList _permList;
		[ARStructMemTypeInfo(Name = "assignedGroupList", Offset = 6u)]
		private ArrayList _assignedGroupList;
		[ARStructMemTypeInfo(Name = "adminGrpList", Offset = 7u)]
		private ArrayList _adminGrpList;
		[ARStructMemTypeInfo(Name = "owners", Offset = 8u)]
		private ArrayList _owners;
		[ARStructMemTypeInfo(Name = "label", Offset = 9u)]
		private string _label;
		[ARStructMemTypeInfo(Name = "description", Offset = 10u)]
		private string _description;
		[ARStructMemTypeInfo(Name = "references", Offset = 11u)]
		protected ArrayList _references;
		[ARStructMemTypeInfo(Name = "helpText", Offset = 12u)]
		private string _helpText;
		[ARStructMemTypeInfo(Name = "owner", Offset = 13u)]
		private string _owner;
		[ARStructMemTypeInfo(Name = "timestamp", Offset = 14u)]
		private DateTime _timestamp;
		[ARStructMemTypeInfo(Name = "lastChanged", Offset = 15u)]
		private string _lastChanged;
		[ARStructMemTypeInfo(Name = "changeDiary", Offset = 16u)]
		private DiaryList _changeDiary;
		[ARStructMemTypeInfo(Name = "objPropList", Offset = 17u)]
		private IDictionary _objPropList;
		[ARStructMemTypeInfo(Name = "modificationLogLabel", Offset = 18u)]
		private string _modificationLogLabel;
		[ARStructMemTypeInfo(Name = "assgnName", Offset = 19u)]
		private string _assgnName;
		private string _newName;
		private BitVector32 _modifyFlags;
		public string Name
		{
			get
			{
				return this._name;
			}
			set
			{
				this._name = value;
			}
		}
		public string NewName
		{
			get
			{
				return this._newName;
			}
			set
			{
				if (this._newName == value || this._newName == this._name)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 2);
				this._newName = value;
			}
		}
		public ArrayList Permissions
		{
			get
			{
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 4);
				return this._permList;
			}
			set
			{
				if (this._permList == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 4);
				this._permList = value;
			}
		}
		public ArrayList AssignedGroupList
		{
			get
			{
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 65536);
				return this._assignedGroupList;
			}
			set
			{
				if (this._assignedGroupList == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 65536);
				this._assignedGroupList = value;
			}
		}
		public ArrayList AdminGroups
		{
			get
			{
				return this._adminGrpList;
			}
			set
			{
				this._adminGrpList = value;
			}
		}
		public ArrayList ContainerOwners
		{
			get
			{
				return this._owners;
			}
			set
			{
				this._owners = value;
			}
		}
		public string Label
		{
			get
			{
				return this._label;
			}
			set
			{
				this._label = value;
			}
		}
		public string Description
		{
			get
			{
				return this._description;
			}
			set
			{
				this._description = value;
			}
		}
		internal ArrayList References
		{
			get
			{
				return ArrayList.ReadOnly(this._references);
			}
			set
			{
				this._references = value;
			}
		}
		public string HelpText
		{
			get
			{
				return this._helpText;
			}
			set
			{
				if (this._helpText == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 512);
				this._helpText = value;
			}
		}
		public string Owner
		{
			get
			{
				return this._owner;
			}
			set
			{
				if (this._owner == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 1024);
				this._owner = value;
			}
		}
		public DiaryList ChangeDiary
		{
			get
			{
				return this._changeDiary;
			}
			set
			{
				if (this._changeDiary == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 2048);
				this._changeDiary = value;
			}
		}
		public IDictionary Properties
		{
			get
			{
				return this._objPropList;
			}
			set
			{
				if (this._objPropList == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 4096);
				this._objPropList = value;
			}
		}
		public DateTime LastUpdateTime
		{
			get
			{
				return this._timestamp;
			}
		}
		public string LastModifiedBy
		{
			get
			{
				return this._lastChanged;
			}
		}
		public string ModificationLogLabel
		{
			get
			{
				return this._modificationLogLabel;
			}
			set
			{
				if (this._modificationLogLabel == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 32768);
				this._modificationLogLabel = value;
			}
		}
		public string AssignedName
		{
			get
			{
				return this._assgnName;
			}
			set
			{
				if (this._assgnName == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 131072);
				this._assgnName = value;
			}
		}
		[ComVisible(false)]
		public BitVector32 MembersModified
		{
			get
			{
				return this._modifyFlags;
			}
			set
			{
				this._modifyFlags = value;
			}
		}
		public int MembersModifiedAsInt
		{
			get
			{
				return this._modifyFlags.get_Data();
			}
			set
			{
				this._modifyFlags = new BitVector32(value);
			}
		}
		public Container()
		{
			this.References = new ArrayList();
		}
		internal Container(object[] rawData, Server server)
		{
			this.Name = (string)Util.GetAt(rawData, new int[]
			{
				3
			});
			this.Permissions = ARTypeMgr.Instance.ArrayListFromVariant(Type.GetType("Unknown"), (object[])Util.GetAt(rawData, new int[]
			{
				5
			}), server);
			this.AssignedGroupList = ARTypeMgr.Instance.ArrayListFromVariant(Type.GetType("Unknown"), (object[])Util.GetAt(rawData, new int[]
			{
				6
			}), server);
			this.AdminGroups = ARTypeMgr.Instance.ArrayListFromVariant(Type.GetType("System.UInt32"), (object[])Util.GetAt(rawData, new int[]
			{
				7
			}), server);
			this.ContainerOwners = ARTypeMgr.Instance.ArrayListFromVariant(Type.GetType("BMC.ARSystem.ContainerOwner"), (object[])Util.GetAt(rawData, new int[]
			{
				8
			}), server);
			this.Label = (string)Util.GetAt(rawData, new int[]
			{
				9
			});
			this.Description = (string)Util.GetAt(rawData, new int[]
			{
				10
			});
			this.References = ARTypeMgr.Instance.ArrayListFromVariant(Type.GetType("BMC.ARSystem.Reference"), (object[])Util.GetAt(rawData, new int[]
			{
				12
			}), server);
			this.HelpText = (string)Util.GetAt(rawData, new int[]
			{
				13
			});
			this.Owner = (string)Util.GetAt(rawData, new int[]
			{
				14
			});
			this._timestamp = Util.GetDateTime(Convert.ToUInt32(Util.GetAt(rawData, new int[]
			{
				15
			})));
			this._lastChanged = (string)Util.GetAt(rawData, new int[]
			{
				16
			});
			this.ChangeDiary = DiaryList.Decode((string)Util.GetAt(rawData, new int[]
			{
				17
			}));
			ARTypeMgr arg_241_0 = ARTypeMgr.Instance;
			Type arg_241_1 = typeof(HybridDictionary);
			string arg_241_2 = "System.Int32";
			int[] keyIndex = new int[1];
			this.Properties = arg_241_0.BuildCustomDictionaryFromVariant(arg_241_1, arg_241_2, keyIndex, "ARValue", new int[]
			{
				1
			}, (object[])Util.GetAt(rawData, new int[]
			{
				18
			}), server);
			this._modifyFlags = new BitVector32(1);
		}
		public void AddItem(Reference item)
		{
			this.MembersModified = new BitVector32(this.MembersModified.get_Data() | 256);
			this._references.Add(item);
		}
		protected int FindItemIndexByRefType(int refType)
		{
			return this.FindItemIndexByRefType(0, refType);
		}
		protected int FindItemIndexByRefType(int startIndex, int refType)
		{
			int i = startIndex;
			int count = this._references.get_Count();
			while (i < count)
			{
				Reference reference = this._references.get_Item(i) as Reference;
				if (reference != null && reference.ReferenceType == refType)
				{
					return i;
				}
				i++;
			}
			return -1;
		}
		protected Reference GetItemByRefType(int refType)
		{
			return this.GetItemByRefType(0, refType);
		}
		protected Reference GetItemByRefType(int startIndex, int refType)
		{
			int num = this.FindItemIndexByRefType(startIndex, refType);
			if (num == -1)
			{
				return null;
			}
			return (Reference)this._references.get_Item(num);
		}
		protected void SetItemByRefType(Reference reference)
		{
			this.SetItemByRefType(0, reference);
		}
		protected void SetItemByRefType(int startIndex, Reference reference)
		{
			int index = this.FindItemIndexByRefType(startIndex, reference.ReferenceType);
			this.SetItemByIndex(index, reference);
		}
		protected void SetItemByIndex(int index, Reference reference)
		{
			this._modifyFlags = new BitVector32(this.MembersModified.get_Data() | 256);
			if (index >= 0 && index < this._references.get_Count())
			{
				this._references.RemoveAt(index);
				this._references.Insert(index, reference);
				return;
			}
			this.AddItem(reference);
		}
		private int FindMax(int[] vals)
		{
			int num = vals[0];
			for (int i = 0; i < vals.Length; i++)
			{
				int num2 = vals[i];
				if (num2 > num)
				{
					num = num2;
				}
			}
			return num;
		}
		protected ArrayList GetAnchoredRefValue(int anchoredRefType, int numParts, int[] offsets, int[] refTypes, bool includeAnchor)
		{
			ArrayList arrayList = new ArrayList();
			int num = this.FindItemIndexByRefType(anchoredRefType);
			if (num >= 0 && num + numParts < this.References.get_Count())
			{
				if (includeAnchor)
				{
					arrayList.Add(this.References.get_Item(num));
				}
				for (int i = 0; i < offsets.Length; i++)
				{
					Reference reference = this.References.get_Item(num + offsets[i]) as Reference;
					if (reference != null && reference.ReferenceType == refTypes[i])
					{
						arrayList.Add(reference);
					}
				}
			}
			return arrayList;
		}
		protected ArrayList GetAnchoredMultiValRefValues(int anchoredRefType, int numParts, int[] offsets, int[] refTypes, bool anchorRepeats)
		{
			ArrayList arrayList = new ArrayList();
			int num = this.FindItemIndexByRefType(anchoredRefType);
			bool flag = false;
			if (num != -1 && !anchorRepeats)
			{
				num++;
			}
			while (num >= 0 && num + numParts <= this.References.get_Count())
			{
				ArrayList arrayList2 = new ArrayList(numParts);
				int i = 0;
				int num2 = offsets.Length;
				while (i < num2)
				{
					Reference reference = this.References.get_Item(num + offsets[i]) as Reference;
					if (reference == null || reference.ReferenceType != refTypes[i])
					{
						flag = true;
						break;
					}
					arrayList2.Add(reference);
					i++;
				}
				if (flag)
				{
					break;
				}
				arrayList.Add(arrayList2);
				num += numParts;
			}
			return arrayList;
		}
		internal static Container createInstance(object[] rawData, Server server)
		{
			switch ((uint)rawData[11])
			{
			case 1u:
				return new ActiveLinkGuide(rawData, server);
			case 2u:
				return new ApplicationContainer(rawData, server);
			case 3u:
				return new PackingList(rawData, server);
			case 4u:
				return new FilterGuide(rawData, server);
			case 5u:
				return new WebServiceContainer(rawData, server);
			default:
				return new ActiveLinkGuide();
			}
		}
	}
}
